package com.woniuxy.three.pms.data.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.three.pms.data.DataOperation;

@Controller
public class DataController {

	@PostMapping("/data")
	@ResponseBody
	public String backups() {
		String hostIP = "127.0.0.1";
		String userName = "root";
		String password = "q12345";
		String savePath = "D:\\testsql";
		String fileName = "pms";
		String databaseName = "pms";
		boolean boo = DataOperation.backup(hostIP, userName, password, savePath, fileName, databaseName);
		if(boo) {
			return "备份成功";
		}
		return "备份失败";
	}
	
	@GetMapping("/data")
	@ResponseBody
	public String reduction() {
		String filepath = "D:\\testsql\\pms.sql";
		String ip = "127.0.0.1";
		String database = "pms";
		String userName = "root";
		String password = "q12345";
		boolean boo = DataOperation.recover(filepath, ip, database, userName, password);
		if(boo) {
			return "还原成功";
		}
		return "还原失败";
	}
	
}
